<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>影厅更新</title>
    <link th:include="common::com_css">
    <script th:src="@{/static/js/myJs/input.js}"></script>

</head>

<body class="sticky-header">
<section>
    <div th:replace="common :: #com_leftmenu"></div>
    <div class="main-content">
        <div th:replace="common :: #com_headermenu"></div>
        <div class="wrapper">
            <div th:replace="common :: #com_alert"></div>
            <form class="form-horizontal" th:if="${screens}!=null" th:action="@{/updateScreens}" role="form" name="updateScreensFrom" method="post" enctype="multipart/form-data" onsubmit="return flag()">
                <input type="hidden" th:value="${screens.id}" name="id">
                <!--影厅名称-->
                <div class="form-group">
                    <label for="screensName" class="col-lg-1 col-sm-1 control-label">影厅名称</label>
                    <div class="col-lg-11">
                        <input type="text"name="screensName" th:value="${screens.screensName}" class="form-control" id="screensName" oninput="titleInput('screensName','t_screensName',20)" placeholder="影厅名称" required>
                        <p id="t_screensName" class="help-block">请输入影厅的名称（字数限制20字）</p>
                    </div>
                </div>


                <!--影厅类型-->
                <div class="form-group">
                    <label for="type" class="col-lg-1 col-sm-1 control-label">影厅类型</label>
                    <div class="col-lg-11">
                        <input type="text"name="type" th:value="${screens.type}" class="form-control" id="type" oninput="titleInput('type','t_screensType',25)" placeholder="影厅类型" required>
                        <p id="t_screensType" class="help-block">请输入影厅的类型（字数限制25字）</p>
                    </div>
                </div>
                <!--座位数-->
                <div class="form-group">
                    <label for="seatingNum" class="col-lg-1 col-sm-1 control-label">座位数</label>
                    <div class="col-lg-11">
                        <input type="number"max="1000" th:value="${screens.seatingNum}" readonly min="1" name="seatingNum" class="form-control" id="seatingNum" oninput="titleInput('seatingNum','t_seatingNum',4)" placeholder="座位数" required>
                        <p id="t_seatingNum" class="help-block">影厅座位数（不可修改）</p>
                    </div>
                </div>

                <div class="form-group">
                    <label for="state" class="col-lg-1 col-sm-1 control-label">影厅状态</label>
                    <div class="col-lg-11">
                        <input type="hidden" th:value="${screens.state}" id="f_state">
                        <select class="form-control" id="state" name="state" required>
                            <option value="1">启用</option>
                            <option value="0">未启用</option>
                        </select>
                        <p id="t_state" class="help-block">请选择影厅状态</p>
                    </div>
                </div>


                <!--表单提交按钮-->
                <div class="form-group">
                    <div class="col-lg-offset-1 col-lg-3">
                        <button type="submit" class="btn btn-success btn-lg btn-block">修改影厅</button>
                    </div>
                </div>
            </form>
        </div>
        <footer class="sticky-footer">
            2021 &copy; <a href="https://github.com/ZhangHeng0805" target="_blank">星曦向荣</a>
        </footer>
    </div>
</section>

<div th:include="common::#com_js"></div>
<script>
    function set_select_checked(selectId, checkValue){
        var select = document.getElementById(selectId);
        for (var i = 0; i < select.options.length; i++){
            if (select.options[i].value == checkValue){
                select.options[i].selected = true;
                break;
            }
        }
    }
    var val=$("#f_state").val()
    set_select_checked('state',val)
</script>

</body>
</html>